/*
 * EditLineDialog.java
 * 
 * Created by demory on Sep 6, 2009, 8:56:23 PM
 * 
 * Copyright 2008 David D. Emory
 * 
 * This file is part of Five Points. See <http://www.fpdev.org> for
 * additional information regarding the project.
 * 
 * Five Points is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Five Points is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Five Points.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.fpdev.apps.cart.gui;

import org.fpdev.util.gui.ColorChooserDialog;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.BevelBorder;
import javax.swing.border.EmptyBorder;
import org.fpdev.util.gui.GUIFactory;
import org.fpdev.apps.cart.network.Line;

/**
 *
 * @author demory
 */


/*public class EditLineDialog extends JDialog implements ActionListener {

  private JButton colorBtn_;
  private JPanel colorPanel_;
  private Color chosenColor_;

  private JTextField widthField_, offsetField_;

  private JTextField monthField_, yearField_;

  private JButton okBtn_, cancelBtn_;

  private Line line_;

  private boolean okPressed_ = false;

  public EditLineDialog(CartGUI gui, Line line) {
    super(gui, "Edit Line Properties", true);
    line_ = line;


    // color row

    chosenColor_ = line.getStyle().getColor();

    colorPanel_ = new JPanel();
    colorPanel_.setMaximumSize(new Dimension(12,12));
    colorPanel_.setBackground(chosenColor_);
    colorPanel_.setBorder(new BevelBorder(BevelBorder.LOWERED));

    colorBtn_ = GUIFactory.newButton("Choose..", 75, this);

    JPanel colorRow = GUIFactory.newRowPanel();
    colorRow.setAlignmentX(LEFT_ALIGNMENT);
    colorRow.add(GUIFactory.newLabel("Color: "));
    colorRow.add(Box.createHorizontalStrut(5));
    colorRow.add(colorPanel_);
    colorRow.add(Box.createHorizontalStrut(5));
    colorRow.add(colorBtn_);

    // width/offset row

    widthField_ = GUIFactory.newTextField(""+line.getStyle().getWidth(), 0, 25);
    offsetField_ = GUIFactory.newTextField(""+line.getStyle().getBaseOffset(), 0, 25);

    JPanel widthOffsetRow = GUIFactory.newRowPanel();
    widthOffsetRow.setAlignmentX(LEFT_ALIGNMENT);
    widthOffsetRow.add(GUIFactory.newLabel("Width:"));
    widthOffsetRow.add(Box.createHorizontalStrut(5));
    widthOffsetRow.add(widthField_);
    widthOffsetRow.add(Box.createHorizontalStrut(5));
    widthOffsetRow.add(GUIFactory.newLabel("Offset:"));
    widthOffsetRow.add(Box.createHorizontalStrut(5));
    widthOffsetRow.add(offsetField_);


    // date open row
    
    monthField_ = GUIFactory.newTextField(""+line.getOpenMonth(), 0, 25);
    yearField_ = GUIFactory.newTextField(""+line.getOpenYear(), 0, 50);

    JPanel dateOpenRow = GUIFactory.newRowPanel();
    dateOpenRow.setAlignmentX(LEFT_ALIGNMENT);
    dateOpenRow.add(GUIFactory.newLabel("Date Open: "));
    dateOpenRow.add(monthField_);
    dateOpenRow.add(yearField_);

    // button row

    okBtn_ = GUIFactory.newButton("OK", 50, this);
    cancelBtn_ = GUIFactory.newButton("Cancel", 50, this);

    JPanel btnRow = GUIFactory.newRowPanel();
    btnRow.setAlignmentX(LEFT_ALIGNMENT);
    btnRow.add(Box.createHorizontalGlue());
    btnRow.add(okBtn_);
    btnRow.add(cancelBtn_);
    btnRow.add(Box.createHorizontalGlue());

    JPanel mainPanel = GUIFactory.newColumnPanel();
    mainPanel.setBorder(new EmptyBorder(5,5,5,5));

    mainPanel.add(colorRow);
    mainPanel.add(Box.createVerticalStrut(5));
    mainPanel.add(widthOffsetRow);
    mainPanel.add(Box.createVerticalStrut(5));
    mainPanel.add(dateOpenRow);
    mainPanel.add(Box.createVerticalStrut(5));
    mainPanel.add(btnRow);

    getContentPane().add(mainPanel);
    setSize(250, 150);
    //pack();
    setLocationRelativeTo(gui);
    setVisible(true);
  }

  public void actionPerformed(ActionEvent e) {
    if(e.getSource() == okBtn_) okPressed_ = true;
    if(e.getSource() == okBtn_ || e.getSource() == cancelBtn_) setVisible(false);

    if(e.getSource() == colorBtn_) {
      ColorChooserDialog chooserDialog = new ColorChooserDialog(this, chosenColor_);
      chosenColor_ = chooserDialog.getColor();
      colorPanel_.setBackground(chosenColor_);
    }
  }

  public boolean okPressed() { return okPressed_; }

  public Color getColor() {
    return chosenColor_;
  }

  public int getLineWidth() {
    return Integer.parseInt(widthField_.getText());
  }

  public int getOffset() {
    return Integer.parseInt(offsetField_.getText());
  }

  public int getMonth() {
    if(monthField_.getText().isEmpty()) return 0;
    return Integer.parseInt(monthField_.getText());
  }

  public int getYear() {
    if(yearField_.getText().isEmpty()) return 0;
    return Integer.parseInt(yearField_.getText());
  }
}*/
